package com.lol.controller;


import com.lol.model.EbProduct;
import com.lol.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("product")
public class ProductController {
    @Resource
    private ProductService productService;

    @RequestMapping("/detail")
    public String detail (Model model, int pid){
        System.out.println("ProductDetail的detail方法。。。。pid"+pid);
        EbProduct productDetail = productService.detail(pid);
        model.addAttribute("productDetail" , productDetail);
        return "product-view";
    }

    @RequestMapping("/add_car")
    public String addCar(int epId, HttpServletRequest request){
        //1.TODO 调用service将商品加入购物车
        productService.addCar(epId,request);
        //2.TODO 绑定数据到model
        //不需要因为service已经将数据放到service中了
        //3.TODO 返回view --html
        return "shopping";
    }
}
